//
//  ViewController.m
//  RACPrepareProject
//
//  Created by tianchao wu on 2017/7/10.
//  Copyright © 2017年 tianchao wu. All rights reserved.
//

#import "ViewController.h"
#import "NSObject+Caculator.h"
#import "Caculator.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    /*
     * add(1)
     * 1.调用add返回一个block
     * 2.block调用参数(1)
     */
    int result = [NSObject makeCaculators:^(CaculatorMaker *make) {
        make.add(1).add(2).add(3).add(4).divide(5);
    }];
    
    NSLog(@"result = %d",result);
    
    // 2*5==10
    Caculator *c = [[Caculator alloc] init];
    
    //计算2*5，并且判断是否等于10
    BOOL isEqual = [[[c caculator:^int(int result) {
        result += 2;
        result *= 5;
        return result;
    }] equal:^BOOL(int result) {
        return result==10;
    }] isEqual];
    NSLog(@"isEqual = %d",isEqual);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
